function plot_pattern_count_distribution(filename,sheet_name)
    % 读取Excel文件中的指定工作表
    data = readtable(filename, 'Sheet', sheet_name);
    
    % 提取count列数据
    counts = data.Count;
    
    % 创建图形窗口
    figure('Units','centimeters','Position',[6,10,16,7]);
    
    % 使用histogram绘制直方图
    h1 = histogram(counts, 'BinMethod', 'auto');
    
    % 设置图表属性
    title('Count Distribution of Patterns');
    xlabel('Count Ranges');
    ylabel('Number of Patterns');

    % 在柱子上方显示频数
    show_text_on_bar(h1)

    % 设置x轴刻度为bin边界
    xticks(h1.BinEdges);

    % 创建图形窗口
    figure('Units','centimeters','Position',[6,10,16,7]);

    % 使用histogram绘制百分比直方图
    h2 = histogram(counts, 'Normalization', "percentage", 'BinMethod', 'auto');
    ytickformat("percentage");

    % 设置图表属性
    title('Count Distribution of Patterns');
    xlabel('Count Ranges');
    ylabel('Percentage of Patterns');

    % 设置x轴刻度为bin边界
    xticks(h2.BinEdges);

end

function show_text_on_bar(bar_handle)
    for i = 1:length(bar_handle.Values)
        text(mean([bar_handle.BinEdges(i), bar_handle.BinEdges(i + 1)]), ...
            bar_handle.Values(i), ...
            num2str(bar_handle.Values(i)), ...
            'HorizontalAlignment', 'center', ...
            'VerticalAlignment', 'bottom');
    end
end
